<?php

/* @auther wf
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

class Import {

	/**
     * 删除导入错误信息
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _delimporterror($where = '') {
		$sql = 'DELETE FROM "{{import_error}}" ' . $where;
		Yii::app()->db->createCommand($sql)->execute();
	}

	/**
     * 删除学生信息
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _delstudent($where = '') {
		$sql = 'DELETE FROM "{{student}}" ' . $where;
		Yii::app()->db->createCommand($sql)->execute();
	}

	/**
     * 删除教师信息
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _delteacher($where = '') {
		$sql = 'DELETE FROM "{{teacher}}" '.$where;
		Yii::app()->db->createCommand($sql)->execute();
	}
	/**
     * 获取学生信息
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _getstudentinfo($userid = '') {
		$sql = 'SELECT * FROM "{{user_school}}" WHERE "user_id" =' . $userid;
		$studentinfo = Yii::app()->db->createCommand($sql)->queryRow();
		return $studentinfo;
	}

	/**
     * 获取学生信息
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _getdisciplininfo($where = '') {
		$sql = 'SELECT * FROM "{{disciplin}}" ' . $where;
		$disciplininfo = Yii::app()->db->createCommand($sql)->queryRow();
		return $disciplininfo;
	}

	/**
     * 检测学生信息是否存在
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _checkstudentinfo($where = '') {
		$sql = 'SELECT * FROM "{{student}}" ' . $where;
		$studentinfo = Yii::app()->db->createCommand($sql)->queryRow();
		return $studentinfo;
	}

	/**
     * 检测导入错误信息
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _checkimporterror($where = '') {
		$sql = 'SELECT "excel_row" FROM "{{import_error}}" ' . $where;
		$error_rows = Yii::app()->db->createCommand($sql)->queryAll();
		return $error_rows;
	}

	/**
     * 检测学生成绩是否存在
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _checkstudentsocre($where = '') {
		$sql = ' SELECT * FROM "{{point}}" ' . $where;
		$pointinfo = Yii::app()->db->createCommand($sql)->queryRow();
		return $pointinfo;
	}
	/**
     * 得到表字段详情
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _gettableinfo($table = '') {
		if($table == 'student'){
			//$sql = 'SELECT "student_id","student_name","exam_id","exam_code","city_code","city_name","school_id","school_code","school_name","class_name","student_sex","socre","disciplin_code","disciplin_name","disciplin_type","statis","nature","interstellar","roll","ywkgf","ywzgf","ywzwf","ywfjf","ywf","sxtkf","sxjdf","sxfjf","sxf","yykgf","yyzgf","yyzwf","yyf","wlkgf","wlzgf","wlf","hxkgf","hxzgf","hxf","swkgf","swzgf","swf","lskgf","lszgf","lsf","zzkgf","zzzgf","zzf","dlkgf","dlzgf","dlf","yswzf","yswzfhfjf","track","default_statis","ramark","addtime","uptime" FROM USER_COL_COMMENTS WHERE TABLE_NAME='."'"."{{student}}"."'";
			$sql = "SELECT * FROM USER_COL_COMMENTS WHERE TABLE_NAME='{{".$table."}}' order by comments asc";
		}else{
			$sql = "SELECT * FROM USER_COL_COMMENTS WHERE TABLE_NAME='{{".$table."}}' order by comments asc";
		}
		$data =  Yii::app()->db->createCommand($sql)->queryAll();

		return $data;
	}
	/**
     * 表用到的数据类型
     * @version 1.0
     * @date 2013-12-14
     * @author wf
     */
	static function _gettabletype() {
		return array(
		'varchar'=>'字符型',
		'int'=>'数值型',
		'float'=>'小数型',
		'bit'=>'逻辑型'
		);
	}


}

?>